# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Contributor: Stefan Wagner <stw@bit-strickerei.de>
# Maintainer: Stefan Wagner <stw@bit-strickerei.de>
pkgname=munin
pkgver=2.0.67
pkgrel=0
pkgdesc="A distributed monitoring/graphing tool"
url="http://munin-monitoring.org/"
arch="noarch"
license="GPL-2.0-only"
_perl_modules="perl-rrd perl-net-snmp perl-log-log4perl perl-html-template
	perl-net-ssleay perl-net-server perl-date-manip perl-io-socket-inet6
	perl-file-copy-recursive perl-fcgi perl-uri"
depends="$pkgname-node"
makedepends="bash rrdtool perl-dev perl-module-build $_perl_modules"
pkgusers=munin
pkggroups=munin
subpackages="$pkgname-node"
source="$pkgname-$pkgver.tar.gz::https://github.com/munin-monitoring/munin/archive/refs/tags/$pkgver.tar.gz
	munin-config.patch
	fix-build.patch
	$pkgname.crond
	$pkgname-node.initd
	$pkgname.logrotate
	$pkgname-node.logrotate"

build() {
	make -j1
}

package() {
	make DESTDIR="$pkgdir" install-master-prime
	rm -rf "$pkgdir"/usr/share/man

	install -m644 -D "$srcdir"/$pkgname.crond \
		"$pkgdir"/etc/munin/munin.cron.sample
	install -m644 -D "$srcdir"/$pkgname.logrotate \
		"$pkgdir"/etc/logrotate.d/$pkgname

	install -d -o $pkgusers -g $pkggroups "$pkgdir"/usr/share/webapps/munin/html
}

node() {
	depends="bash rrdtool perl $_perl_modules"
	install="$subpkgname.pre-install"

	cd "$builddir"

	mkdir -p "$subpkgdir"
	make DESTDIR="$subpkgdir" install-common-prime install-node-prime \
		install-plugins-prime
	rm -rf "$subpkgdir"/usr/share/man

	install -m644 -D "$srcdir"/$subpkgname.logrotate \
		"$pkgdir"/etc/logrotate.d/$subpkgname
	install -m755 -D "$srcdir"/$subpkgname.initd \
		"$subpkgdir"/etc/init.d/$subpkgname
}

sha512sums="
a8381491dfa15572438d9acda7a09feb0c3918ebe49e7bcfce5c172b36b4a5a0472bd6d06f5fad41270af0510b3fe115509d146f372df7fa47ed4aa1ec5f95d4  munin-2.0.67.tar.gz
d39760b9c0546638feaf164ad132a0f384f1b70872de2251a328a27a64797501f926141a7273cd5e41a8c11ec4d7a4adda1863b02439d9caa8b216fac60d3062  munin-config.patch
0c2c257ab1b218fa87439de6b5b73782492143bf625cdf18481fff97d648446554c5e1decb6dd44c8803b0ccf1eb6949398da261876093963a8230eda1afe0a8  fix-build.patch
194b742b2ff8312c4c42a8a77d1d9a80bc53ced2343248c36f4229b0b0d366e898487fb5e415f1f5ccea7210a7a86e25de5e45193dbb5d26d2d6a195f0597642  munin.crond
ee055a2bcb0ee3895190ac28b9474a50896e9c6d8f88bb93bc00fd802f313c00bc92fcbb46e22c545fb1c111d63398725c09a8bf7adc8a8977e1832b19f61044  munin-node.initd
0f4768033f63103cb41b3f3869ebe378098f85409a909afa311a49587cb6afcffe2b2199821cd41a08f41bbeba3d37121561406978960e3345fbccfd230040e6  munin.logrotate
34cdc04e83067d2fc839efaf06d96da892d76b77555a4b7b633f9a88fb86dc5f4413fe7a4f6c540e95724b23e8a4ad0ff37f521d44046bfcf18cb0428b94e6e2  munin-node.logrotate
"
